#!/bin/sh

if [ -z "$1" ]
then
	echo "input is null"
	exit 0
fi

echo "------------------ reset git repo to $1 ------------------ "

git pull $1
#git fetch $1
#git reset --hard $1/master

match_results=$(find ../WavePatterns/out/ -type f -name "match_*")
for match in $match_results; do
	cp  "$match" ./
done
git add match_*.json

tdx_stocks="../WavePatterns/resources/tdx_stocks.json"
if [ -f "$tdx_stocks" ]; then
	cp  "$tdx_stocks" ./
	git add tdx_stocks.json
fi

pytdx_fininfo="../WavePatterns/data/pytdx_fininfo.json"
if [ -f "$pytdx_fininfo" ]; then
	cp  "$pytdx_fininfo" ./
	git add pytdx_fininfo.json
fi


cur_date="`date +%Y-%m-%d`"
git commit -m "1. update wave_patten results at  "$cur_date

#git push -f $1
git push $1

echo "------------------- push to "$1" ------------------ "

